<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改物品')" />
    <th:block th:include="include :: datetimepicker-css" />
    <th:block th:include="include :: bootstrap-fileinput-css"/>
    <th:block th:include="include :: layui-css"/>
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-goods-edit" th:object="${erpGoods}">
            <input name="goodsId" th:field="*{goodsId}" type="hidden">
            <div class="form-group">    
                <label class="col-sm-3 control-label">物品名：</label>
                <div class="col-sm-8">
                    <input name="goodName" th:field="*{goodName}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">父节点：</label>
                <div class="col-sm-8">
                    <div class="input-group">
                        <input id="treeId" name="parentId" type="hidden" th:field="*{parentId}" />
                        <input class="form-control" type="text" onclick="selectGoodsTree()" id="treeName" readonly="true" th:field="*{parentName}">
                        <span class="input-group-addon"><i class="fa fa-search"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">提醒：</label>
                <div class="col-sm-8">
                    <input name="attention" th:field="*{attention}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">项目：</label>
                <div class="col-sm-8">
                    <select id="projectId"  th:field="*{projectId}"  name="projectId"  class="form-control"  required>
                        <!--                                    <option value="">所有</option>-->
                        <option  th:each="item:${@erpService.selectErpProjectList()}"
                                 th:text="${item.projectName}"
                                 th:value="${item.projectId}"></option>
                    </select>
<!--                    <input name="projectId" th:field="*{projectId}" class="form-control" type="text" required>-->
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">项目名：</label>
                <div class="col-sm-8">
                    <input name="projectName" th:field="*{projectName}" class="form-control" type="text">
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label">图号：</label>
                <div class="col-sm-8">
                    <input name="drawingNo" th:field="*{drawingNo}" class="form-control" type="text">
                </div>
            </div>

            <div class="form-group">    
                <label class="col-sm-3 control-label">总数：</label>
                <div class="col-sm-8">
                    <input name="totalNumber" th:field="*{totalNumber}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">材质：</label>
                <div class="col-sm-8">
                    <input name="goodsMaterial" th:field="*{goodsMaterial}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">单重：</label>
                <div class="col-sm-8">
                    <input name="itemWeight" th:field="*{itemWeight}" class="form-control" type="text">
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label">单台数量：</label>
                <div class="col-sm-8">
                    <input name="quantityUnit" th:field="*{quantityUnit}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">总重：</label>
                <div class="col-sm-8">
                    <input name="totalWeight" th:field="*{totalWeight}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">单价：</label>
                <div class="col-sm-8">
                    <input name="itemPrice" th:field="*{itemPrice}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">总价：</label>
                <div class="col-sm-8">
                    <input name="totalPrice" th:field="*{totalPrice}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">供货商名称：</label>
                <div class="col-sm-8">
                    <input name="supplierName" th:field="*{supplierName}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">采购数：</label>
                <div class="col-sm-8">
                    <input name="purchasesNum" th:field="*{purchasesNum}" class="form-control" type="text">
                </div>
            </div>
<!--            <div class="form-group">    -->
<!--                <label class="col-sm-3 control-label">采购数绑定员工：</label>-->
<!--                <div class="col-sm-8">-->
<!--                    <input name="purchasesNumMemberId" th:field="*{purchasesNumMemberId}" class="form-control" type="text">-->
<!--                </div>-->
<!--            </div>-->
            <div class="form-group">    
                <label class="col-sm-3 control-label">质检数：</label>
                <div class="col-sm-8">
                    <input name="inspectionNum" th:field="*{inspectionNum}" class="form-control" type="text">
                </div>
            </div>


            <div class="form-group">
                <label class="col-sm-3 control-label">出货时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="deliveryTime" th:value="${#dates.format(erpGoods.deliveryTime, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>


            <div class="form-group">    
                <label class="col-sm-3 control-label">质检数绑定员工：</label>
                <div class="col-sm-8">
                    <input name="inspectionNumMemberId" th:field="*{inspectionNumMemberId}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">入库数：</label>
                <div class="col-sm-8">
                    <input name="stockNum" th:field="*{stockNum}" class="form-control" type="text">
                </div>
            </div>
<!--            <div class="form-group">    -->
<!--                <label class="col-sm-3 control-label">入库数绑定员工：</label>-->
<!--                <div class="col-sm-8">-->
<!--                    <input name="stockNumMemberId" th:field="*{stockNumMemberId}" class="form-control" type="text">-->
<!--                </div>-->
<!--            </div>-->
            <div class="form-group">    
                <label class="col-sm-3 control-label">出库数：</label>
                <div class="col-sm-8">
                    <input name="outboundNum" th:field="*{outboundNum}" class="form-control" type="text">
                </div>
            </div>
<!--            <div class="form-group">    -->
<!--                <label class="col-sm-3 control-label">出库数绑定员工：</label>-->
<!--                <div class="col-sm-8">-->
<!--                    <input name="outboundNumMemberId" th:field="*{outboundNumMemberId}" class="form-control" type="text">-->
<!--                </div>-->
<!--            </div>-->
            <div class="form-group">
                <label class="col-sm-3 control-label">多图：</label>
                <div class="col-sm-8">
<!--                    <textarea name="pictureUrl" class="form-control">[[*{pictureUrl}]]</textarea>-->
                    <input name="pictureUrl" th:field="*{pictureUrl}" type="hidden" id="resultImg">
                    <div class="file-loading">
                        <input name="file" id="imgUpload" type="file">
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">图片备注：</label>
                <div class="col-sm-8">
                    <input name="pictureRemark" th:field="*{pictureRemark}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">视频：</label>
                <div class="col-sm-8">
<!--                    <textarea name="videoUrl" class="form-control">[[*{videoUrl}]]</textarea>-->

                    <video id="videoSrc" th:src="${erpGoods.videoUrl}"  width="100"  height="100" controls="controls">
                    </video>
                    <input id="videoUrlFile" type="file" />
                    <input type="button" value="上传" onclick="videoUrlFileUpload();" />
                    <input  id="videoUrl" name="videoUrl" th:field="*{videoUrl}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">视频备注：</label>
                <div class="col-sm-8">
                    <input name="videoRemark" th:field="*{videoRemark}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">工艺：</label>
                <div class="col-sm-8">
                    <input name="technology" th:field="*{technology}" class="form-control" type="text">
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label">加工员：</label>
                <div class="col-sm-8">
                    <input name="processor" th:field="*{processor}" class="form-control" type="text">
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label">加工时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="processorTime" th:value="${#dates.format(erpGoods.processorTime, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>


            <div class="form-group">
                <label class="col-sm-3 control-label">质检员：</label>
                <div class="col-sm-8">
                    <input name="qualityInspectorName" th:field="*{qualityInspectorName}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">质检时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="qualityInspectorTime" th:value="${#dates.format(erpGoods.qualityInspectorTime, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">结果：</label>
                <div class="col-sm-8">
                    <input name="result" th:field="*{result}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <input name="remark" th:field="*{remark}" class="form-control" type="text">
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />



    <th:block th:include="include :: bootstrap-fileinput-js"/>
    <th:block th:include="include :: layui-js"/>


    <script src="/js/common/oneImgUpload.js"></script>
    <script src="/js/common/imgUpload.js"></script>


    <script th:inline="javascript">
        var prefix = ctx + "erp/goods";
        $("#form-goods-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            $("#projectId").trigger("change");
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-goods-edit').serialize());
            }
        }

        $('#projectId').change(() => {
            $('#projectName').val($('#projectId').find("option:selected").text());
        });

        $("input[name='qualityInspectorTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });
        $("input[name='deliveryTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='processorTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        /*物品-编辑-选择父物品树*/
        function selectGoodsTree() {
            var options = {
                title: '物品选择',
                width: "380",
                url: prefix + "/selectGoodsTree/" + $("#treeId").val(),
                callBack: doSubmit
            };
            $.modal.openOptions(options);
        }


        $(function() {

            imageUploadEdit($("#imgUpload"),$("#resultImg"));



        });

        /*视频上传*/
        function videoUrlFileUpload(){

            var type = "file";          //后台接收时需要的参数名称，自定义即可
            var id = "cert";            //即input的id，用来寻找值
            var formData = new FormData();
            formData.append(type, $("#videoUrlFile")[0].files[0]);    //生成一对表单属性
            $.ajax({
                type: "POST",           //因为是传输文件，所以必须是post
                url: '/common/uploadVideo',         //对应的后台处理类的地址
                data: formData,
                processData: false,
                contentType: false,
                success: function (data) {
                    console.info(data.msg);
                    $("#videoUrl").val(data.msg);
                    $("#videoSrc").attr("src", data.msg);
                }
            });
        }
        function doSubmit(index, layero){
            var body = layer.getChildFrame('body', index);
               $("#treeId").val(body.find('#treeId').val());
               $("#treeName").val(body.find('#treeName').val());
               layer.close(index);
        }
    </script>
</body>
</html>